<?php

namespace Admin\Controller;

use Common\Controller\AdminbaseController;

class QiusysController extends AdminbaseController {
    public function index() {
        $p=1;
        if (isset($_GET['p'])){
            $p=$_GET['p'];
        }
        $queryDesc='order by id';
        
        $postData=array();
        $where='';
        $postData['p']=$p;

        if (isset($_POST['name']) && !empty($_POST['name'])){
            $postData['name']=addslashes(trim($_POST['name']));
            $where=' where name like "%'.$postData['name'].'%" or phone="'.$_POST['name'].'" ';
        }
        
        $Model = M();
        $query=$Model->query("SELECT count(id) as count FROM `uinfo` ".$where."  ");
        $count=$query[0]['count'];
        $page = $this->page($count, 10, $p);
        $uInfo=$Model->query("SELECT * FROM `uinfo` ".$where."  ".$queryDesc." limit ".(($p-1)*10).",10 ");
        $theData=array();
        include '/var/www/chongya/web/thearray.php';
        foreach ($uInfo as $v){
           
            if (isset($v['zubie'])){
                if (isset($zuBie[$v['zubie']])){
                    $zbie=$zuBie[$v['zubie']];
                }else{
                    $zbie=$v['zubie'];
                }
            }else{
                $zbie=getZuByAge($v['age']);
            }
            
            $checkJoin=$Model->query(" SELECT * FROM `joinqiu` where openid='".$v['openid']."' limit 0,1 ");
            $weizhi='';
            if (isset($checkJoin[0]['weizhi'])){
                $weizhi=$weizhiList[$checkJoin[0]['weizhi']];
            }
            $qiuhao='';
            if (isset($checkJoin[0]['qiuhao'])){
                $qiuhao=$checkJoin[0]['qiuhao'];
            }
            
            $shenpi='';
            $qiuDName='';
            if (isset($checkJoin[0]['isapply'])){
                $isapply=$checkJoin[0]['isapply'];
                if (0 == $isapply){
                    $shenpi='未审核: 球员';
                }
                if (1 == $isapply){
                    $shenpi='已加入: 球员';
                }
                
                $getQdui=$Model->query(" SELECT name FROM `qdui` where id='".$checkJoin[0]['qiuid']."' limit 0,1 ");
                $qiuDName=$getQdui[0]['name'];
                
            }
            
            $checkQdui=$Model->query(" SELECT name FROM `qdui` where openid='".$v['openid']."' limit 0,1 ");

            if (isset($checkQdui[0]['name']) && !empty($checkQdui[0]['name'])){
                $shenpi='队长';
                $qiuhao=99;
                $qiuDName=$checkQdui[0]['name'];
            }
            
            $theData[]=array('id'=>$v['id'],'name'=>$v['name'],'zubie'=> $zbie ,
                'gao'=> $v['gao'] ,'weight'=> $v['weight'] ,'idcard'=> $v['idcard'] ,
                'phone'=> $v['phone'] ,'weizhi'=>$weizhi,'qiuhao'=>$qiuhao,
                'createtime'=>$v['createtime'],'shenpi'=>$shenpi,'qiuDName'=>$qiuDName
            );
        }
        $this->assign("postData", $postData);
        $this->assign("page", $page->show('Admin'));
        $this->assign("thedata", $theData);

        $this->display();
    }
    
  
   
 
}
